<template>
  <div id="main">
    <div id="sidebar">
      <div class="panel">
        <div class="header">
          <span class="col_fade">个人信息</span>
        </div>
        <div class="inner">
          <div class="user_card">
            <div>
              <a class="user_avatar" :href="'/user/'+user.loginname">
                <img :src="user.avatar_url" class="user_avatar" :title="user.avatar_url">
              </a>
              <span class="user_name"><a class="dark" :href="'/user/'+user.loginname">{{user.loginname}}</a></span>
              <div class="board clearfix">
                <div class="floor">
                  <span class="big">积分: {{user.score}} </span>
                </div>
              </div>
              <div class="space clearfix"></div>
            </div>
          </div>
        </div>
      </div>
      <div class="panel">
        <div class="header">
          <span class="col_fade">友情社区</span>
        </div>
        <div class="inner">
          <ol class="friendship-community">
            <li>
              <a href="https://ruby-china.org/" target="_blank">
                <img src="//static2.cnodejs.org/public/images/ruby-china-20150529.png">
              </a>
            </li>
            <div class="sep10"></div>
            <li>
              <a href="http://golangtc.com/" target="_blank">
                <img src="//static2.cnodejs.org/public/images/golangtc-logo.png">
              </a>
            </li>
            <div class="sep10"></div>
            <li>
              <a href="http://phphub.org/" target="_blank">
                <img src="//static2.cnodejs.org/public/images/phphub-logo.png">
              </a>
            </li>
          </ol>
        </div>
      </div>
      <div class="panel">
        <div class="header">
          <span class="col_fade">客户端二维码</span>
        </div>
        <div class="inner cnode-app-download">
          <img width="200" src="//static.cnodejs.org/FtG0YVgQ6iginiLpf9W4_ShjiLfU">
          <br>
          <a href="https://github.com/soliury/noder-react-native" target="_blank">客户端源码地址</a>
        </div>
      </div>
    </div>
    <div id="content">
      <div class="panel">
        <div class="header">
          <ul class="breadcrumb">
            <li><a href="/">主页</a><span class="divider">/</span></li>
          </ul>
        </div>
        <div class="inner userinfo">
          <div class="user_big_avatar">
            <img :src="user.avatar_url" class="user_avatar" :title="user.avatar_url">
          </div>
          <a class="dark">{{user.loginname}}</a>
          <div class="user_profile">
            <ul class="unstyled">
              <span class="big">{{user.score}}</span> 积分
            </ul>
          </div>
          <p class="col_fade">注册时间 {{user.create_at.substring(0,10)}}</p>
        </div>
      </div>
      <div class="panel">
        <div class="header">
          <span class="col_fade">最近创建的话题</span>
        </div>

        <div class="cell" v-for="item in user.recent_topics">
          <NuxtLink class="user_avatar pull-left" to="/user/thonatos">
            <img :src="item.author.avatar_url" :title="item.author.loginname">
          </NuxtLink>

          <span class="last_time pull-right">
                <span class="last_active_time">{{item.last_reply_at.substring(0,10)}}</span>
              </span>
          <div class="topic_title_wrapper">
            <NuxtLink class="topic_title" :to="'/topic/'+item.id" :title="item.title"> {{item.title}}</NuxtLink>
          </div>
        </div>

        <div class="cell more">
          <a class="dark" href="/user/thonatos/topics">查看更多»</a>
        </div>

      </div>

      <div class="panel">
        <div class="header">
          <span class="col_fade">最近参与的话题</span>
        </div>

        <div class="cell" v-for="item in user.recent_replies">
          <NuxtLink class="user_avatar pull-left" to="/user/thonatos">
            <img :src="item.author.avatar_url" :title="item.author.loginname">
          </NuxtLink>

          <span class="last_time pull-right">
                <span class="last_active_time">{{item.last_reply_at.substring(0,10)}}</span>
              </span>
          <div class="topic_title_wrapper">
            <NuxtLink class="topic_title" :to="'/topic/'+item.id" :title="item.title"> {{item.title}}</NuxtLink>
          </div>
        </div>

        <div class="cell more">
          <a class="dark" href="/user/thonatos/replies">查看更多»</a>
        </div>

      </div>
    </div>


  </div>
</template>

<script>
  import {user} from "../../assets/js/api";

  export default {
    name: "user",
    head(){
      return {
        title:this.user.githubUsername +'的个人主页',
        meta:[
          { hid: 'description', name: 'description', content: this.user.githubUsername +'的个人主页' }
        ]
      }
    },
    data(){
      return {
        user:{
          loginname:'',
          githubUsername:'',
          create_at:''
        }
      }
    },
    async asyncData({$axios,params}){
      let data = await user({axios:$axios,params});
      if(!data) return
      return {
        user:data
      }
    }
  }
</script>

<style scoped>
  .user_avatar{margin-right: 5px;}
</style>
